<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html class="bg-black">
<head>
<meta charset="UTF-8">
<title>微店-登录</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- bootstrap 3.0.2 -->
<link href="${pageContext.request.contextPath}/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- font Awesome -->
    <link href="${pageContext.request.contextPath}/static/bootstrap/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
        <link href="${pageContext.request.contextPath}/static/bootstrap/css/ALTE.css" rel="stylesheet" type="text/css" />
            <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
            <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
            <!--[if lt IE 9]>
            <script src="${pageContext.request.contextPath}/static/bootstrap/html5shiv.js"></script>
                <script src="${pageContext.request.contextPath}/static/bootstrap/respond.min.js"></script>
                    <![endif]-->
                    <style>
                    .codeBtn{
                        position:relative;
                        color:blue;
                        top:7px;
                        left:75%;
                        z-index:99;
                    }
                    </style>
                    </head>
                    <body class="bg-black">
                    <div class="form-box" id="login-box">
                    <div class="header">微店-登录</div>
                    <div>
                    <div class="body bg-gray">
                    <div class="form-group">
                    <label>登录名</label>
                    <input id="name" name="name" type="text" placeholder="请输入登录名"  class="form-control ">
                    </div>
                    <div class="form-group">
                    <label>密码</label>
                    <input id="password" name="password" type="password" placeholder="请输入密码"  class="form-control ">
                    </div>
                     

                
                   
                    
                <div class="form-group">
                  
                	<input name="loginType" type="radio" value="1" id="loginType1" /><label style="color:black" for="loginType1">管理员 </label>
                	
                	<input name="loginType" type="radio" value="2" id="loginType2" /><label style="color:black" for="loginType2">用户 </label>
                	
                  </div>
                
                 
                    </div>
                    <div class="footer">
                    <button type="button"  onclick="submitForm()" class="btn bg-olive btn-block">登录 </button>
                     
                   <a  href="UserRegistServlet?method=goRegist" onclick="" >注册用户</a>
                   
                    </div>
                    </div>
                    <div class="margin text-center">
                    <span>Copyright  微店</span>
                    </div>
                    </div>
                    <!-- jQuery 2.0.2 -->
                    <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/jquery-1.11.1.min.js"></script>
                        <!-- Bootstrap -->
                        <script src="${pageContext.request.contextPath}/static/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
                            <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/utils/listutils.js?v=26573"></script>
                                <script>

 function submitForm(){
 var loginType = $("input[name='loginType']:checked").val();
  $.ajax({
			  type: 'post',
			   url: 'LoginServlet?method=validLogin',
			   data: {
			   	'loginType':loginType,
			   	'name':$("#name").val(),
			 	'password':$("#password").val()
			   },
				  success: function(result) {
					result=$.parseJSON(result);
					if(result.code==0){
				  		alert(result.msg);
					}
				  if(result.code==1){
			   	if(loginType==1){
			   		window.location.href="AdminIndexServlet?method=goIndex";	
				}
			   	if(loginType==2){
			   		window.location.href="UserIndexServlet?method=goIndex";	
				}
				 }
 }
  });
 }

                              </script>
                                                            </body>
                                                            </html>
